package com.haredot.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haredot.entity.Collect;
import com.haredot.holder.TokenContextHolder;
import com.haredot.service.CollectService;
import com.haredot.mapper.CollectMapper;
import com.haredot.vo.CollectVO;
import com.haredot.vo.R;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @author Administrator
* @description 针对表【tb_collect】的数据库操作Service实现
* @createDate 2023-09-05 21:09:53
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect>  implements CollectService{

    @Override
    public R<Page<CollectVO>> queryCollectsByPage(Page<CollectVO> page) {
        // 获取当前登录的用户
        Long userId = TokenContextHolder.getCurrentUserId();

        // 分页查询该用户收藏的所有的资源
        Page<CollectVO> data = this.getBaseMapper().findCollectListByPage(page, userId);

        return R.<Page<CollectVO>>ok().data(data);
    }
}




